import { EntitySchema } from '@mikro-orm/core';

export class ImsYzdKpGoodOrder {
  id!: number;
  uniacid!: number;
  userId!: number;
  ordercode!: string;
  outTradeNo!: string;
  totalPrice!: string;
  totalPayPrice!: string;
  expressOriginalPrice!: string;
  expressPrice!: string;
  totalGoodsOriginalPrice!: string;
  totalGoodsPrice!: string;
  useUserCouponId: number = 0;
  couponDiscountPrice!: string;
  sRemark?: unknown;
  webRemark?: unknown;
  submitTime!: string;
  isPay: boolean = false;
  payType: number = 0;
  payTime?: string;
  isSale: number = 0;
  cancelState: boolean = false;
  cancelTime?: string;
  saleState: boolean = false;
  refundResult!: boolean;
  refundState: boolean = false;
  refundContent?: unknown;
  refundImg?: unknown;
  expressId?: number = 0;
  expressNo!: string;
  isConfirm: boolean = false;
  confirmTime!: string;
  sendType: boolean = false;
  isComment: number = 0;
  commentTime!: string;
  shouhouState: boolean = false;
  refundKdgsBh!: string;
  refundKdgsName!: string;
  autoCancelTime?: string;
  autoSalesTime!: string;
  autoConfirmTime!: string;
  distributePrice?: string;
  surplusPrice?: string;
  integral: number = 0;
  type: number = 1;
  name?: string;
  phone?: string;
  address?: unknown;
  remark?: unknown;
  isSend: boolean = false;
  sendTime?: string;
  express?: string;
  backPrice!: string;
  provinceId: number = 0;
  cityId: number = 0;
  districtId: number = 0;
  deviceType?: number;
  baidu?: unknown;
  payData?: unknown;
  goodType: number = 1;
}

export const ImsYzdKpGoodOrderSchema = new EntitySchema({
  class: ImsYzdKpGoodOrder,
  properties: {
    id: { primary: true, type: 'number' },
    uniacid: { type: 'number', index: 'uniacid' },
    userId: { type: 'number', index: 'user_id' },
    ordercode: { type: 'string', length: 255, index: 'ordercode' },
    outTradeNo: { type: 'string', length: 255 },
    totalPrice: { type: 'string', columnType: 'numeric(10,2)' },
    totalPayPrice: { type: 'string', columnType: 'numeric(10,2)' },
    expressOriginalPrice: { type: 'string', columnType: 'numeric(10,2)', defaultRaw: `0.00` },
    expressPrice: { type: 'string', columnType: 'numeric(10,2)', defaultRaw: `0.00` },
    totalGoodsOriginalPrice: { type: 'string', columnType: 'numeric(10,2)', defaultRaw: `0.00` },
    totalGoodsPrice: { type: 'string', columnType: 'numeric(10,2)', defaultRaw: `0.00` },
    useUserCouponId: { type: 'number', default: 0 },
    couponDiscountPrice: { type: 'string', columnType: 'numeric(10,2)', defaultRaw: `0.00` },
    sRemark: { type: 'unknown', columnType: 'longtext', nullable: true },
    webRemark: { type: 'unknown', columnType: 'longtext', nullable: true },
    submitTime: { type: 'string', length: 255 },
    isPay: { type: 'boolean', default: false, index: 'is_pay' },
    payType: { type: 'number', default: 0 },
    payTime: { type: 'string', length: 255, nullable: true, default: '0' },
    isSale: { type: 'number', columnType: 'tinyint', default: 0 },
    cancelState: { type: 'boolean', default: false },
    cancelTime: { type: 'string', length: 255, nullable: true },
    saleState: { type: 'boolean', default: false },
    refundResult: { type: 'boolean' },
    refundState: { type: 'boolean', default: false },
    refundContent: { type: 'unknown', columnType: 'longtext', nullable: true },
    refundImg: { type: 'unknown', columnType: 'longtext', nullable: true },
    expressId: { type: 'number', nullable: true, default: 0 },
    expressNo: { type: 'string', length: 255, default: '0' },
    isConfirm: { type: 'boolean', default: false },
    confirmTime: { type: 'string', length: 255 },
    sendType: { type: 'boolean', default: false },
    isComment: { type: 'number', columnType: 'tinyint', default: 0 },
    commentTime: { type: 'string', length: 255 },
    shouhouState: { type: 'boolean', default: false },
    refundKdgsBh: { type: 'string', length: 255 },
    refundKdgsName: { type: 'string', length: 255 },
    autoCancelTime: { type: 'string', length: 255, nullable: true, default: '0' },
    autoSalesTime: { type: 'string', length: 255, default: '0' },
    autoConfirmTime: { type: 'string', length: 255, default: '0' },
    distributePrice: { type: 'string', columnType: 'numeric(10,2)', nullable: true },
    surplusPrice: { type: 'string', columnType: 'numeric(10,2)', nullable: true },
    integral: { type: 'number', default: 0 },
    type: { type: 'number', default: 1 },
    name: { type: 'string', length: 255, nullable: true },
    phone: { type: 'string', length: 255, nullable: true },
    address: { type: 'unknown', columnType: 'longtext', nullable: true },
    remark: { type: 'unknown', columnType: 'longtext', nullable: true },
    isSend: { type: 'boolean', default: false },
    sendTime: { type: 'string', length: 255, nullable: true },
    express: { type: 'string', length: 255, nullable: true },
    backPrice: { type: 'string', columnType: 'numeric(10,2)', defaultRaw: `0.00` },
    provinceId: { type: 'number', default: 0 },
    cityId: { type: 'number', default: 0 },
    districtId: { type: 'number', default: 0 },
    deviceType: { type: 'number', fieldName: 'deviceType', nullable: true },
    baidu: { type: 'unknown', columnType: 'longtext', nullable: true },
    payData: {
      type: 'unknown',
      fieldName: 'payData',
      columnType: 'longtext',
      nullable: true,
    },
    goodType: { type: 'number', default: 1 },
  },
});
